<?php

namespace App\Containers\AppSection\Settings\Actions;

use App\Containers\AppSection\Settings\Tasks\FindSettingByKeyTask;
use App\Containers\AppSection\Settings\Tasks\UpdateSettingTask;
use App\Ship\Parents\Actions\Action;
use App\Ship\Parents\Requests\Request;

class UpdateSettingAction extends Action
{
    public function run($key, Request $request)
    {
        $setting = app(FindSettingByKeyTask::class)->run($key);

        return app(UpdateSettingTask::class)->run($setting->id, ['value' => $request->getInputByKey('value')]);
    }
}
